From 5e1a06d1b124f09a1a54d5ae0f38905dbdc2cc81 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 15 Mar 2013 23:10:39 -0400 Subject: [PATCH] GtkGrid: Tweak size allocation If there are rows that contain only spanning children, our algorithm was unnecessarily distributing extra space to the other rows, even if they contain only non-expanding children. We improve the behaviour by treating rows containing only spanning children as expanding. --- gtk/gtkgrid.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c index 571f8266f2..e1df436e80 100644 --- a/gtk/gtkgrid.c +++ b/gtk/gtkgrid.c @@ -562,6 +562,7 @@ gtk_grid_request_init (GtkGridRequest *request, lines->lines[i].minimum = 0; lines->lines[i].natural = 0; lines->lines[i].expand = FALSE; + lines->lines[i].empty = TRUE; } for (list = priv->children; list; list = list->next) @@ -569,8 +570,18 @@ gtk_grid_request_init (GtkGridRequest *request, child = list->data; attach = &child->attach[orientation]; - if (attach->span == 1 && gtk_widget_compute_expand (child->widget, orientation)) + if (attach->span != 1) + continue; + if (gtk_widget_compute_expand (child->widget, orientation)) lines->lines[attach->pos - lines->min].expand = TRUE; + + lines->lines[attach->pos - lines->min].empty = FALSE; + } + + for (i = 0; i < lines->max - lines->min; i++) + { + if (lines->lines[i].empty) + lines->lines[i].expand = TRUE; } } @@ -903,6 +914,8 @@ gtk_grid_request_compute_expand (GtkGridRequest *request, for (i = 0; i < attach->span; i++) { line = &lines->lines[attach->pos - lines->min + i]; + if (line->empty) + line->expand = TRUE; line->empty = FALSE; if (line->expand) has_expand = TRUE; -- 2.30.2